<!-------------------------------------------------- Header --------------------------------------------->
<?php include 'header_page.php'; ?>
<!-------------------------------------------------- Content -------------------------------------------->
<?php 
require_once('system/dbconnector.php');
$connection = new DBConnection();
$connection->connect();
?>   
<div id="templatemo_main_top"></div>
<div id="templatemo_main">
	
<div id="content" class="float_l">

<?php 
$query = "SELECT * FROM news as N WHERE TYPE=1 AND DATE = (SELECT MAX(DATE) FROM news WHERE TYPE=1) LIMIT 1";
$result = mysql_query($query);
$row = mysql_fetch_row($result);
?>
 
<div class="post">
        <h3>Thông Tin Bất Động Sản</h3>
            	<a href="news_detail.php?id=<?php echo $row[0]; ?>"><img src="images/news/<?php echo $row[7]; ?>" width="280" height="210"/></a>
                <h2><?php echo $row[2]; ?></h2>
                <p align="justify"><?php  echo $row[3]; ?></p>
                 <a href="news_detail.php?id=<?php echo $row[0]; ?>" class="more">Xem thêm</a>
                 <div class="cleaner"></div>
                 <div class="meta">
                 <span class="admin">Bất Động Sản</span><span class="date"><?php $raw_date = strtotime($row[5]); $date = date('d/m/Y',$raw_date); echo $date; ?></span><span class="tag"><a href="#">Nguồn Tin: </a><a href="#"><?php echo $row[6]; ?></a></span><span class="comment"></span>
                    <div class="cleaner"></div>
                </div>
            	 <div class="cleaner"></div>
</div>

<?php 
$query = "SELECT * FROM news as N WHERE TYPE=2 AND DATE = (SELECT MAX(DATE) FROM news WHERE TYPE=2) LIMIT 1";
$result = mysql_query($query);
$row = mysql_fetch_row($result);
?>

<div class="post">
        <h3>Thông Tin Xây Dựng</h3>
            	<a href="news_detail.php?id=<?php echo $row[0]; ?>"><img src="images/news/<?php echo $row[7]; ?>" width="280" height="210"/></a>
                <h2><?php echo $row[2]; ?></h2>
                <p align="justify"><?php  echo $row[3]; ?></p>
                 <a href="news_detail.php?id=<?php echo $row[0]; ?>" class="more">Xem thêm</a>
                 <div class="cleaner"></div>
                 <div class="meta">
                    <span class="admin">Xây Dựng, Thi Công</span><span class="date"><?php $raw_date = strtotime($row[5]); $date = date('d/m/Y',$raw_date); echo $date; ?></span><span class="tag"><a href="#">Nguồn Tin: </a><a href="#"><?php echo $row[6]; ?></a></span><span class="comment"></span>
                    <div class="cleaner"></div>
                </div>
            	 <div class="cleaner"></div>
</div>
            
            
            
            
            
            
<?php 
$query = "SELECT * FROM news as N WHERE TYPE=3 AND DATE = (SELECT MAX(DATE) FROM news WHERE TYPE=3) LIMIT 1";
$result = mysql_query($query);
$row = mysql_fetch_row($result);
?>

<div class="post">
        <h3>Thông Tin Xe Hơi</h3>
            	<a href="news_detail.php?id=<?php echo $row[0]; ?>"><img src="images/news/<?php echo $row[7]; ?>" width="280" height="210"/></a>
                <h2><?php echo $row[2]; ?></h2>
                <p align="justify"><?php  echo $row[3]; ?></p>
                 <a href="news_detail.php?id=<?php echo $row[0]; ?>" class="more">Xem thêm</a>
                 <div class="cleaner"></div>
                 <div class="meta">
                 <span class="admin">Xe Ô tô</span><span class="date"><?php $raw_date = strtotime($row[5]); $date = date('d/m/Y',$raw_date); echo $date; ?></span><span class="tag"><a href="#">Nguồn Tin: </a><a href="http://<?php echo $row[6]; ?>"><?php echo $row[6]; ?></a></span><span class="comment"></span>
                    <div class="cleaner"></div>
                </div>
            	 <div class="cleaner"></div>
</div>
            
        
    </div>
    <div id="sidebar" class="float_r">
<h5>Danh mục thể loại</h5>
        <ul class="templatemo_list">
            <li><a href="news/news_real_estate.php">Bất Động Sản, Đầu Tư</a></li>
            <li><a href="news/news_construction.php">Thi công công trình, xây dựng</a></li>
        	<li><a href="news/news_car.php">Xe hơi, máy móc</a></li>           
        </ul>
        <div class="cleaner h20"></div>
<h5>Các tin đăng gần đây</h5>
        
<?php 
$query = "SELECT * FROM news as N WHERE TYPE=1 AND DATE = (SELECT MAX(DATE) FROM news WHERE TYPE=1) LIMIT 1";
$result = mysql_query($query);
$row = mysql_fetch_row($result);
?>
<div class="rp_pp">
<a href="news_detail.php?id=<?php echo $row[0]; ?>"><?php echo $row[2]; ?></a>
<p><?php $raw_date = strtotime($row[5]); $date = date('d/m/Y',$raw_date); echo $date; ?> - <?php echo $row[6]; ?> - Bất Động Sản</p>
<div class="cleaner"></div>
</div>
<?php 
$query = "SELECT * FROM news as N WHERE TYPE=2 AND DATE = (SELECT MAX(DATE) FROM news WHERE TYPE=2) LIMIT 1";
$result = mysql_query($query);
$row = mysql_fetch_row($result);
?>
<div class="rp_pp">
<a href="news_detail.php?id=<?php echo $row[0]; ?>"><?php echo $row[2]; ?></a>
<p><?php $raw_date = strtotime($row[5]); $date = date('d/m/Y',$raw_date); echo $date; ?> - <?php echo $row[6]; ?> - Thi Công, Xây Dựng</p>
<div class="cleaner"></div>
</div>

<?php 
$query = "SELECT * FROM news as N WHERE TYPE=3 AND DATE = (SELECT MAX(DATE) FROM news WHERE TYPE=3) LIMIT 1";
$result = mysql_query($query);
$row = mysql_fetch_row($result);
?>
<div class="rp_pp">
<a href="news_detail.php?id=<?php echo $row[0]; ?>"><?php echo $row[2]; ?></a>
<p><?php $raw_date = strtotime($row[5]); $date = date('d/m/Y',$raw_date); echo $date; ?> - <?php echo $row[6]; ?> - Xơi Hơi, Máy Móc</p>
<div class="cleaner"></div>
</div>

<div class="cleaner h20"></div>

<h5>Danh Mục Đọc Nhiều Nhất</h5>
<?php 
$query = "SELECT * FROM news WHERE TYPE=1 ORDER BY ID DESC LIMIT 2";
$result = mysql_query($query);
while($row = mysql_fetch_row($result))
{
	$raw_date = strtotime($row[5]); $date = date('d/m/Y',$raw_date);
	echo '<div class="rp_pp">
			<a href="news_detail.php?id='.$row[0].'">'.$row[2].'</a>
			<p>'.$date.' - '.$row[6].' - Bất Động Sản</p>
			<div class="cleaner"></div>
		</div>';
}
?>
       
<?php 
$query = "SELECT * FROM news WHERE TYPE=2 ORDER BY ID DESC LIMIT 2";
$result = mysql_query($query);
while($row = mysql_fetch_row($result))
{
	$raw_date = strtotime($row[5]); $date = date('d/m/Y',$raw_date);
	echo '<div class="rp_pp">
			<a href="news_detail.php?id='.$row[0].'">'.$row[2].'</a>
			<p>'.$date.' - '.$row[6].' - Thi Công, Xây Dựng</p>
			<div class="cleaner"></div>
		</div>';
}
?>

<?php 
$query = "SELECT * FROM news WHERE TYPE=3 ORDER BY ID DESC LIMIT 2";
$result = mysql_query($query);
while($row = mysql_fetch_row($result))
{
	$raw_date = strtotime($row[5]); $date = date('d/m/Y',$raw_date);
	echo '<div class="rp_pp">
			<a href="news_detail.php?id='.$row[0].'">'.$row[2].'</a>
			<p>'.$date.' - '.$row[6].' - Xe Hơi, Máy Móc</p>
			<div class="cleaner"></div>
		</div>';
}
?>

</div>
        
<div class="cleaner h40"></div>
        
    </div>
    <div class="cleaner"></div>
</div> <!-- END of main -->
<?php $connection->disconnect(); ?>
<!-------------------------------------------------- Footer --------------------------------------------->
<?php include 'footer_page.php'; ?>